package com.san.hkhospital.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.san.hkhospital.vo.RoomTableVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.san.hkhospital.entity.Room;
import com.san.hkhospital.mapper.RoomMapper;
import com.san.hkhospital.entity.RoomExample;
import com.san.hkhospital.service.RoomService;
import org.springframework.transaction.annotation.Transactional;

/**
 * ClassName:RoomServiceImpl
 * PackageName:com.san.hkhospital.service.impl
 * Description:
 *
 * @Author:yy
 * @CreatedAt:2024/11/13 14:38
 * 
 */
 
 
@Service
@Transactional
public class RoomServiceImpl implements RoomService{

    @Resource
    private RoomMapper roomMapper;

    @Override
    public long countByExample(RoomExample example) {
        return roomMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(RoomExample example) {
        return roomMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Integer roomId) {
        return roomMapper.deleteByPrimaryKey(roomId);
    }

    @Override
    public int insert(Room record) {
        return roomMapper.insert(record);
    }

    @Override
    public int insertSelective(Room record) {
        return roomMapper.insertSelective(record);
    }

    @Override
    public List<Room> selectByExample(RoomExample example) {
        return roomMapper.selectByExample(example);
    }

    @Override
    public Room selectByPrimaryKey(Integer roomId) {
        return roomMapper.selectByPrimaryKey(roomId);
    }

    @Override
    public int updateByExampleSelective(Room record,RoomExample example) {
        return roomMapper.updateByExampleSelective(record,example);
    }

    @Override
    public int updateByExample(Room record,RoomExample example) {
        return roomMapper.updateByExample(record,example);
    }

    @Override
    public int updateByPrimaryKeySelective(Room record) {
        return roomMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Room record) {
        return roomMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Room> selectRoom() {

        return roomMapper.selectByExample(null);
    }

    @Override
    public boolean addRoom(Room room) {
        return roomMapper.insertSelective(room)>0?true:false;
    }


    @Override
    public int updateRoom(Room room) {
        return roomMapper.updateByPrimaryKey(room);
    }

    @Override
    public Room findOneRoom(Integer roomId) {
        Room room = roomMapper.selectByPrimaryKey(roomId);
        return room;
    }

    @Override
    public PageInfo selectAll(Integer sectionId,Integer pageNum,Integer pageSize) {
        if (pageNum != null && pageSize != null) {
            PageHelper.startPage(pageNum,pageSize);
        }
        List<RoomTableVo> room = roomMapper.selectAll(sectionId);
        PageInfo pi = new PageInfo<>(room);
        return pi;
    }

}
